"""
Copyright (c) 2022 Huawei Technologies Co.,Ltd.

openGauss is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:

          http://license.coscl.org.cn/MulanPSL2

THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
"""
"""
Case Type   : reindex
Case Name   : 执行reindex system concurrently
Create At   : 2021/12/13
Owner       : @zou_jialiang050
Description :
    1.执行reindex system concurrently
Expect      :
    1.跳过所有系统表,不做任何操作
History     :
"""

import os
import unittest
from yat.test import Node
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger


class SQL(unittest.TestCase):
    def setUp(self):
        self.logger = Logger()
        self.logger.info(f'-----{os.path.basename(__file__)} start-----')
        self.dbuserNode = Node('PrimaryDbUser')
        self.primary_sh = CommonSH('PrimaryDbUser')
        self.Constant = Constant()

    def test_reindex(self):
        self.logger.info(f'-----{os.path.basename(__file__)} start-----')
        step = 'step1:执行reindex system concurrently' \
               'expect:跳过所有系统表,不做任何操作'
        reindex = self.primary_sh.execut_db_sql(
            f'''reindex system concurrently {self.dbuserNode.db_name};''')
        self.logger.info(reindex)
        self.assertNotIn('was reindexed', reindex, "执行失败" + step)

    def tearDown(self):
        self.logger.info('无需清理环境')
        self.logger.info(f'-----{os.path.basename(__file__)} end-----')
